<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/common.jspf"%>
<%@ include file="/common/taglibs.jspf"%>
<html lang="en">
<head>
<!-- jquery datatables -->
<link href="${contextPath}/static/widgets/jquery-datatables/css/jquery.dataTables.css" rel="stylesheet" />
<script src="${contextPath }/static/widgets/jquery-datatables/js/jquery.dataTables.min.js"></script>
<script src="${contextPath }/static/widgets/jquery-datatables/js/jquery.dataTables.bootstrap.js"></script>
</head>
<body>
	<!-- quick view -->
    <h:quickview moduleCode="customer"></h:quickview>	
	<!-- toolbar -->
	<div class="toolbar">	
      <button class="btn btn-small btn-primary" onclick="javascript:location.href='add.do'">
        <i class="icon-plus icon-white"></i>
        <s:message code="btn.add" />
      </button>
      <button type="button" class="btn btn-small" onclick="javascript:$.quickview.switchFilter();">
          <i class="icon-search"></i>&nbsp;
          <s:message code='btn.query' />
      </button>	
      <li:p code="crm.customer.add" sessionKey="SESSION_USER">    
        <button type="button" class="btn btn-small btn-info" onclick="javascript:location.href='toImp.do'">
          <i class="icon-inbox-in"></i> <s:message code="btn.import" /></button>   
      </li:p> 
      <button type="button" class="btn btn-small">
          <i class="icon-inbox-out"></i>&nbsp;
          <s:message code='btn.export' />
      </button> 	
      <div class="btn-group">
        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#"><s:message code="btn.moreAction" /> <span class="caret"></span></a>
        <ul class="dropdown-menu">
          <li><a href="#" onclick="javascript:quick_edit(this, 'quickedit', 'Accounts');return false;"><i class="icon-pencil"></i> <s:message code="btn.editBatch" /></a></li>
                    <li><a href="#" style="color:red;" onclick="javascript:change(this,'changeowner');return false;"><i class="icon-trash"></i> <s:message code="btn.deleteBatch" /></a></li>
          <li><a href="#" onclick="javascript:change(this,'changeowner');return false;"><i class="icon-empty"></i> <s:message code="customer.func.merge" /></a></li>
                    <li class="divider"></li>
                    <li><a href="#" onclick="javascript:change(this,'changeowner');return false;"><i class="icon-email"></i> <s:message code="btn.sendEmail" /></a></li>
                    <li><a href="#" onclick="javascript:change(this,'changeowner');return false;"><i class="icon-phone"></i> <s:message code="btn.sendSms" /></a></li>
        </ul>
      </div>  	
	</div>
	<div class="clear"></div>
	<h:quickview-filter search="${quickviewConfig.search }"></h:quickview-filter>
	<!-- datatable -->
	<div>
      <h:quickview-grid table="${table }" var="row" >
         <div class="action-buttons">
		   <a href="edit.do?id=${row.ID }" class="blue"> <i class="icon-pencil"></i></a>&nbsp;&nbsp; 
           <a href="javascript:;" class="red" onclick="rowDelete(${row.ID});"> <i class="icon-trash"></i></a>
		 </div>
      </h:quickview-grid>    
	  <h:pager params="${requestScope[table.dataset] }" formId="datatable"></h:pager>
	</div>
  
	<!--page specific plugin scripts-->
	<script type="text/javascript">
		$(document).ready(function(){				
			$('.datatable').dataTable();	
			
			var checkboxs = $.webtools.checkboxs({
				checkAll: "#checkAll",
				checkItem: ".checkItem"				
			});
		})		
		
		function batchDelete()
		{					
			if($(".checkItem:checked").length<=0)
			{
				$.webtools.notify({
					type: "notice",
					message: "<s:message code='validate.checkone'/>"
				});
				return;
			}
			var ids = $.webtools.getCheckValuesArray(".checkItem");	
		
			bootbox.confirm("<s:message code='common.delete.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "deleteBatch.json",
						params: {"ids":ids},
						success: function(reply) {
							location.reload();
						}
					});						
				}				
			});		
		}	
				
		function rowDelete(id)
		{			
			bootbox.confirm("<s:message code='common.delete.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "delete.json",
						params: {"id":id},
						success: function(reply) {
							location.reload();
						}
					});					
				}				
			});			
		}		
		</script>
</body>
</html>
